using System;
using System.Collections.Generic;
using System.Text;

namespace Tortuga.Core.TortoiseCommands {
	/// <summary>
	/// Brings up the Tortoise commit dialog containing the files/directories in the path. 
	/// </summary>
	public class CommitCommand : TortoiseCommand {
		private string _logMessage = "";

		public CommitCommand() : base("commit") {
			this.OptionsToBuild = new List<BuildOptionDelegate>(new BuildOptionDelegate[] {
			      BuildPathOption, BuildLogMessage, BuildNoTempFile, BuildCloseOnEnd
			});
		}

		public CommitCommand(params string[] path)
			: this() {
			this.Path = new List<string>(path);
		}

		public CommitCommand(string logMessage):this() {
			this.LogMessage = logMessage;
		}

		/// <summary>
		/// Gets or sets the log message to be sent to the commit dialog.
		/// </summary>
		public string LogMessage {
			get { return _logMessage; }
			set { _logMessage = value; }
		}

		#region Building Log Message
		/// <summary>
		/// Builds an option containing the passed log message.
		/// </summary>
		/// <param name="message">The log message.</param>
		/// <returns>/logmsg:"message"</returns>
		public static string BuildLogMessage(string message) {
			return BuildOption("logmsg", message);
		}

		/// <summary>
		/// Builds an option containing the log message.
		/// </summary>
		/// <returns>/logmsg:"message"</returns>
		public virtual string BuildLogMessage() {
			return BuildLogMessage(LogMessage);
		}
		#endregion
	}
}
